package com.stone.design.practice.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.stone.design.practice.R;

/**
 * @description 利用组合布局来定义相应的视图
 * @Time 2018/4/11 15:10
 * Created by Stone on 2018/4/11.
 */

public class CarView extends RelativeLayout implements View.OnClickListener {

    private TextView tvDescription;
    private TextView tvTitle;
    private ImageView ivHeader;
    private ImageView ivNext;
    public CarView(Context context) {
        super(context);
        init();
    }

    public CarView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CarView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        inflate(getContext(), R.layout.car_view, this);
        setBackgroundColor(getResources().getColor(R.color.colorCard));

        //Add missing top level attributes
        int padding = (int)getResources().getDimension(R.dimen.card_padding);
        setPadding(padding, padding, padding, padding);
        this.tvTitle = findViewById(R.id.title);
        this.tvDescription = findViewById(R.id.description);
        this.ivHeader = findViewById(R.id.header);
        this.ivNext = findViewById(R.id.next);

        ivNext.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Toast.makeText(getContext(), "", Toast.LENGTH_SHORT).show();
    }
}
